package com.itm.lqm.service;

import java.util.List;


import com.itm.lqm.dao.CourseDao;
import com.itm.lqm.entity.Course;
import com.itm.lqm.entity.Student;

public class CourseService {
	CourseDao cd=new CourseDao();
	//查询课程
	public List<Course> findCourseAll(){
		List<Course> list=cd.findCourseAll();
		return list;
	}
	
	//根据cid查询课程
		public Course findCourseBySid(int cid){
			Course c=cd.findCourseByCid(cid);
			return c;
		}	
		//根据tid查询课程
		public Course findCourseByTid(int cid){
			Course c=cd.findCourseByTid(cid);
			return c;
		}
		
	//添加课程
	public boolean addCourse(Course c){
		if(!cd.isExistCid((c.getCid()))){//c.getCid()是servlet从jsp获取的值与isExistCid查询判断数据库是否存在
			
				
				cd.addCourse(c);
			
			return true;
		}else{
			System.out.println("此课程已存在");
			return false;
		}
		
	}
	
	//
	//删除课程
	public boolean deleteCourseBycid(int cid){
				if(cd.isExistCid(cid)){
					cd.deleteCourseBycid(cid);
					return true;
				}else{
					return false;
				}
			}
			//修改课程
	public boolean updateCourse(Course c){
				if(cd.isExistCid(c.getCid())){
					cd.updateCourse(c);
					return true;
				}else{
					return false;
				}
			}
			

}
